package com.yxb.cms.controller.api;


import com.yxb.cms.architect.constant.BussinessCode;
import com.yxb.cms.architect.utils.BussinessMsgUtil;
import com.yxb.cms.domain.dto.BussinessMsg;
import com.yxb.cms.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 系统管理相关api接口
 * @author YXB
 */
@Api(tags = "系统管理", description = "系统管理相关接口",position = 2)
@RestController
@RequestMapping(value = "/api")
@Log4j2
public class SystemControllerApi {


    @Autowired
    private UserService userService;


    @ApiOperation(notes = "根据用户账号查询用户信息", value = "根据用户账号查询",position = 1)
    @RequestMapping(value = "/user_info", method = {RequestMethod.POST})
    @ApiImplicitParams({
        @ApiImplicitParam(name = "appKey", value = "appKey", dataType = "String", required = true, paramType = "query"),
        @ApiImplicitParam(name = "timeStamp", value = "时间戳", dataType = "String", required = true, paramType = "query"),
        @ApiImplicitParam(name = "paras", value = "加密后的参数", dataType = "String", required = true, paramType = "query"),
        @ApiImplicitParam(name = "sign", value = "签名", dataType = "String", required = true, paramType = "query")
    })
    @ResponseBody
    public BussinessMsg selectUserInfo(@RequestParam(value = "appKey") String appKey,
                                       @RequestParam(value = "timeStamp") String timeStamp,
                                       @RequestParam(value = "paras") String paras,
                                       @RequestParam(value = "sign") String sign ) {
        try {
            return userService.selectUserInfo(paras);
        } catch (Exception ex) {
            log.error("方法内部错误{}", ex.getMessage(), ex);
            return BussinessMsgUtil.returnCodeMessage(BussinessCode.GLOBAL_ERROR);
        }
    }










}
